<?php

include_once ('bd/ModeloBD.php');

class ModeloEmpresa extends ModeloBD {

    private $empcodsx;
    private $secempcodsx;
    private $usucodsx;
    private $provinciacodsx;
    private $empnit;
    private $emprazonsocial;
    private $empdescripcion;
    private $emptipo;
    private $empciudad;
    private $empcorreo;
    private $empweb;
    private $empexperiencia;
    private $empverificado;
    private $emplogo;
    private $empestado;
    private $empdireccion;
    private $emptel1;
    private $emptel2;

    public function __construct($empcodsx = "", $secempcodsx = "", $usucodsx = "", $provinciacodsx = "", $empnit = "", $emprazonsocial = "", $empdescripcion = "", $emptipo = "", $empciudad = "", $empcorreo = "", $empweb = "", $empexperiencia = "", $empverificado = "", $emplogo = "", $empestado = "", $empdireccion = "", $emptel1 = "", $emptel2 = "") {

        $this->_oBaseDatos = CBaseDatos::get_instancia();
        $this->_oBaseDatos->conectar();
        $this->_sTabla = "empresa";
        $this->empcodsx = $empcodsx;
        $this->secempcodsx = $secempcodsx;
        $this->usucodsx = $usucodsx;
        $this->provinciacodsx = $provinciacodsx;
        $this->empnit = $empnit;
        $this->emprazonsocial = $emprazonsocial;
        $this->empdescripcion = $empdescripcion;
        $this->emptipo = $emptipo;
        $this->empciudad = $empciudad;
        $this->empcorreo = $empcorreo;
        $this->empweb = $empweb;
        $this->empexperiencia = $empexperiencia;
        $this->empverificado = $empverificado;
        $this->emplogo = $emplogo;
        $this->empestado = $empestado;
        $this->empdireccion = $empdireccion;
        $this->emptel1 = $emptel1;
        $this->emptel2 = $emptel2;
    }

    public function crearEmpresa() {
        $emprazonsocial = $this->emprazonsocial;
        $usucodsx = $this->usucodsx;

        $sSQL = "INSERT INTO $this->_sTabla
                (`secempcodsx`, `usucodsx`, `provinciacodsx`, `empnit`, `emprazonsocial`, `empdescripcion`, `emptipo`, `empciudad`, `empcorreo`, `empweb`, `empexperiencia`, `empverificado`, `emplogo`, `empestado`, `empdireccion`, `emptel1`, `emptel2`) 
               VALUES(null,'$usucodsx',null,'','$emprazonsocial','','','','','','',0,'',1,'','','')";
        $this->execute($sSQL);
    }

    public function getEmpresaByRazonSocial($emprazonsocial) {
        $emp = "";
        $sSQL = "
            SELECT emprazonsocial
            FROM $this->_sTabla   where emprazonsocial='$emprazonsocial'";
        $emp = $this->query_object($sSQL);
//        var_dump($arSucursal['usuario'][0]['usucodsx']); //QUERY
//        var_dump($arSucursal[0]->usucodsx); //QUERY_OBJECT
        return $emp;
    }

    public function getEmpresaByUsuario($usucodsx) {
        $emp = null;
        $sSQL = "
            SELECT *
            FROM $this->_sTabla   where usucodsx='$usucodsx'";
        $emp = $this->query_object($sSQL);
//        var_dump($arSucursal['usuario'][0]['usucodsx']); //QUERY
//        var_dump($arSucursal[0]->usucodsx); //QUERY_OBJECT
        return $emp;
    }

    public function actualizarEmpresa($empcodsx) {

        $secempcodsx = $this->secempcodsx;
        $provinciacodsx = $this->provinciacodsx;
        $empnit = $this->empnit;
        $emptipo = $this->emptipo;
        $empciudad = $this->empciudad;
        $empcorreo = $this->empcorreo;
        $empweb = $this->empweb;
        $emplogo = $this->emplogo;
        $empdireccion = $this->empdireccion;
        $emptel1 = $this->emptel1;
        $emptel2 = $this->emptel2;
        $sSQL = "UPDATE $this->_sTabla
                    SET
                    secempcodsx = '$secempcodsx',
                    provinciacodsx = '$provinciacodsx',
                    empnit = '$empnit',
                    emptipo = '$emptipo',
                    empciudad = '$empciudad',
                    empcorreo = '$empcorreo',
                    empweb = '$empweb',
                    emplogo = '$emplogo',
                    empdireccion = '$empdireccion',
                    emptel1 = '$emptel1',
                    emptel2 = '$emptel2'
                    WHERE empcodsx = $empcodsx";
        $this->execute($sSQL);
    }

    public function getEmpresaById($empcodsx) {
        $arEmpresas = null;
        $sSQL = "
            SELECT *
            FROM $this->_sTabla   where empcodsx=" . $empcodsx;
        $arEmpresas = $this->query_object($sSQL);
//        var_dump($arSucursal['usuario'][0]['usucodsx']); //QUERY
//        var_dump($arSucursal[0]->usucodsx); //QUERY_OBJECT
        return $arEmpresas;
    }

    public function getprovinciacodsx() {
        return $this->provinciacodsx;
    }

    public function setprovinciacodsx($provinciacodsx) {
        $this->provinciacodsx = $provinciacodsx;
    }

    public function getempcodsx() {
        return $this->empcodsx;
    }

    public function setempcodsx($empcodsx) {
        $this->empcodsx = $empcodsx;
    }

    public function getSecempcodsx() {
        return $this->secempcodsx;
    }

    public function setSecempcodsx($secempcodsx) {
        $this->secempcodsx = $secempcodsx;
    }

    public function getUsucodsx() {
        return $this->usucodsx;
    }

    public function setUsucodsx($usucodsx) {
        $this->usucodsx = $usucodsx;
    }

    public function getEmpnit() {
        return $this->empnit;
    }

    public function setEmpnit($empnit) {
        $this->empnit = $empnit;
    }

    public function getEmprazonsocial() {
        return $this->emprazonsocial;
    }

    public function setEmprazonsocial($emprazonsocial) {
        $this->emprazonsocial = $emprazonsocial;
    }

    public function getEmpdescripcion() {
        return $this->empdescripcion;
    }

    public function setEmpdescripcion($empdescripcion) {
        $this->empdescripcion = $empdescripcion;
    }

    public function getEmptipo() {
        return $this->emptipo;
    }

    public function setEmptipo($emptipo) {
        $this->emptipo = $emptipo;
    }

    public function getEmpciudad() {
        return $this->empciudad;
    }

    public function setEmpciudad($empciudad) {
        $this->empciudad = $empciudad;
    }

    public function getEmpcorreo() {
        return $this->empcorreo;
    }

    public function setEmpcorreo($empcorreo) {
        $this->empcorreo = $empcorreo;
    }

    public function getEmpweb() {
        return $this->empweb;
    }

    public function setEmpweb($empweb) {
        $this->empweb = $empweb;
    }

    public function getEmpexperiencia() {
        return $this->empexperiencia;
    }

    public function setEmpexperiencia($empexperiencia) {
        $this->empexperiencia = $empexperiencia;
    }

    public function getEmpverificado() {
        return $this->empverificado;
    }

    public function setEmpverificado($empverificado) {
        $this->empverificado = $empverificado;
    }

    public function getEmplogo() {
        return $this->emplogo;
    }

    public function setEmplogo($emplogo) {
        $this->emplogo = $emplogo;
    }

    public function getEmpestado() {
        return $this->empestado;
    }

    public function setEmpestado($empestado) {
        $this->empestado = $empestado;
    }

    public function getEmpdireccion() {
        return $this->empdireccion;
    }

    public function setEmpdireccion($empdireccion) {
        $this->empdireccion = $empdireccion;
    }

    public function getEmptel1() {
        return $this->emptel1;
    }

    public function setEmptel1($emptel1) {
        $this->emptel1 = $emptel1;
    }

    public function getEmptel2() {
        return $this->emptel2;
    }

    public function setEmptel2($emptel2) {
        $this->emptel2 = $emptel2;
    }

}

?>